<?php
namespace Validation\Controller;

use Think\Controller\RestController;
/**
 * 用于各种接口验证方法扩展
 * 
 * By ZhangHaibin
 * 
 */
class ValidationController extends RestController
{
    /**
     * 设置关键字回复验证
     */
    public function replyKeyWords() {

        if (IS_POST) {
            $keyWords = I('rule_keywords');
            $keyWordArrs = explode(",",$keyWords);
            $duplicateValue = false;
            $replyRule = D('Admin/ReplyRule');
            foreach($keyWordArrs as $value) {
                $condition['rule_keywords'] = $value;
                $returnData = $replyRule->where($condition)->count();
                if ($returnData) {
                    $duplicateValue = $value;
                    break;
                }
            }
            if ($duplicateValue) {
                \Common\Common\print_json_data(500, $duplicateValue, '关键字‘'.$duplicateValue.'’已经存在!');
            } else {
                \Common\Common\print_json_data(200, '', '');
            }

        } else {

            \Common\Common\print_json_data(404, '', '验证请求失败!');
        }

    }
}